﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace IdentityMine.Windows.Eventing
{
    public static class EventManagerEx
    {
        public static RoutedEventEx[] GetRoutedEvents()
        {
            List<RoutedEventEx> lst = new List<RoutedEventEx>();

            RoutedEvent[] ar = EventManager.GetRoutedEvents();

            foreach (RoutedEvent re in ar)
            {
                lst.Add(new RoutedEventEx(re));
            }
            return lst.ToArray();
        }

        public static RoutedEventEx[] GetRoutedEventsForOwner(Type ownerType)
        {
            List<RoutedEventEx> lst = new List<RoutedEventEx>();

            RoutedEvent[] ar = EventManager.GetRoutedEventsForOwner(ownerType);

            foreach (RoutedEvent re in ar)
            {
                lst.Add(new RoutedEventEx(re));
            }
            return lst.ToArray();
        }

        public static void RegisterClassHandler(Type classType, RoutedEventEx routedEvent, Delegate handler)
        {
            EventManager.RegisterClassHandler(classType, routedEvent.RoutedEvent, handler);
        }

        public static void RegisterClassHandler(Type classType, RoutedEventEx routedEvent, Delegate handler, bool handledEventsToo)
        {
            EventManager.RegisterClassHandler(classType, routedEvent.RoutedEvent, handler, handledEventsToo);
        }

        public static RoutedEventEx RegisterRoutedEvent(string name, RoutingStrategy routingStrategy, Type handlerType, Type ownerType)
        {
            return  new RoutedEventEx(EventManager.RegisterRoutedEvent(name, routingStrategy, handlerType, ownerType));
        }
    }
}
